//https://leetcode.cn/problems/the-masseuse-lcci/

class Solution {
public:
    int massage(vector<int>& nums) {
        int n = nums.size();

        if (n == 0)
            return 0;

        vector<int> dpf(n, 0);
        vector<int> dpg(n, 0);

        dpf[0] = nums[0];

        for (int i = 1; i < n; i++)
        {
            dpf[i] = dpg[i - 1] + nums[i];
            dpg[i] = max(dpf[i - 1], dpg[i - 1]);
        }

        return max(dpf[n - 1], dpg[n - 1]);

    }
};